package ruifeng.zcj.dig.base;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

public abstract class ViewPagerFragmentAdapter extends FragmentPagerAdapter {
	private ArrayList<String> tabTitles;
	private ArrayList<FragmentInfo> fragmentInfos;
	private Context context;
	public ViewPagerFragmentAdapter(Context context,FragmentManager fm) {
		super(fm);
		this.context = context;
		fragmentInfos = new ArrayList<FragmentInfo>();
		tabTitles = new ArrayList<String>();
		addPage(tabTitles,fragmentInfos);
	}

	/**
	 * 添加一页
	 */
	public abstract void addPage( ArrayList<String> tabTitles,ArrayList<FragmentInfo> fragmentInfos);
	
	@Override
	public Fragment getItem(int position) {
		FragmentInfo fragmentInfo = fragmentInfos.get(position);
		return Fragment.instantiate(context, fragmentInfo.getClazz().getName(), fragmentInfo.getBundle());
	}

	@Override
	public int getCount() {
		return tabTitles.size();
	}

	/*@Override
	public CharSequence getPageTitle(int position) {
		return tabTitles.get(position);
	}*/
	

}
